var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/work-flow/WFOrgtree.tsx
var WFOrgtree_exports = {};
__export(WFOrgtree_exports, {
  WFOrgtree: () => WFOrgtree
});
module.exports = __toCommonJS(WFOrgtree_exports);
var import_react = require("react");
var import_functionalComponent = require("../../functionalComponent");
var import_util = require("../../util");
async function getOrgTree(params) {
  const { clientSqlFilter = "" } = params;
  let sqlFilter = import_util.iup.isFunction(clientSqlFilter) ? clientSqlFilter() : clientSqlFilter;
  if (sqlFilter && import_util.iup.isString(sqlFilter)) {
    sqlFilter = import_util.iup.CryptoJS.encode(sqlFilter);
  } else {
    sqlFilter = "";
  }
  return await import_util.iup.request.get({
    url: "/basedata/orgTree/getOrgDeptTree"
  });
}
var defaultProps = {
  orgattr: "lg",
  // 14是财务组织树
  isLazyLoad: false,
  isIncludeDept: true,
  isRight: true,
  isActive: true,
  isDeptRight: true,
  sqlName: "",
  selectedorgid: "",
  orglabel: "",
  isFromWM: "",
  isZhinengDept: false
};
var WFOrgtree = (0, import_util.compHoc)((props) => {
  const {
    defaultSelectedFirstNode,
    titleField,
    defaultChange = true,
    params,
    outRef,
    beforeRequest,
    convertNode: originConvertNode,
    ...others
  } = props;
  const convertNode = (0, import_util.useRefCallback)((node, levelIndex) => {
    const newNode = {
      title: node.UserParam === "Y" ? `(${node.OCode})${node.OName}` : node.UserParam === "N" && node.CodeValue ? `(${node.OCode})${node.CodeValue}` : node[titleField || "text"],
      key: node.id,
      ...node,
      PhId: node.id,
      phid: node.PhId
    };
    if (defaultSelectedFirstNode && levelIndex.level === 0 && levelIndex.index === 0) {
      newNode.isSelected = true;
    }
    return originConvertNode ? originConvertNode(newNode, levelIndex) : newNode;
  });
  const requestParams = (0, import_react.useMemo)(() => {
    return { ...defaultProps, ...params };
  }, [params]);
  const request = (0, import_util.useRefCallback)(async (param) => {
    if (await (beforeRequest == null ? void 0 : beforeRequest(param)) !== false) {
      const res = await getOrgTree(param);
      console.log(res, "getOrgTree");
      if (res.code === 0) {
        return res.data;
      } else {
        return [];
      }
    }
    return [];
  });
  return /* @__PURE__ */ React.createElement(
    import_functionalComponent.AsyncTree,
    {
      ref: outRef,
      request,
      params: requestParams,
      convertNode,
      ...others,
      defaultChange
    }
  );
}, "WFOrgtree");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  WFOrgtree
});
